package com.loongtech.bi.cs.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.loongtech.bi.cs.model.AddcashEntity;
import com.loongtech.bi.cs.service.AddcashService;
import com.loongtech.bi.dao.CommonDao;

@Service("addcashServiceImpl")
public class AddcashServiceImpl implements AddcashService {

	@Resource(name = "commonDao")
	private CommonDao commonDao;

	@Override
	public List<AddcashEntity> getAddcash(String day, String userid, String roleid) throws Exception {
		StringBuilder sql = new StringBuilder();
		List<Object> lo = new ArrayList<Object>();
		sql.append("select logtime,platform,serverid,channelid ,mac,userid,cashadd,roleid,rolelevel,totalcash,yuanbaoadd,flag,viplevel,addtype,innerorderid,outerorderid,createtime,productid,addtionmount,ip from realtime_addcash where logday = ? ");
		lo.add(day.replaceAll("-", ""));
		if (!"".equals(userid)) {
			sql.append(" and userid = ? ");
			lo.add(userid);
		}
		if (!"".equals(roleid)) {
			sql.append(" and roleid = ? ");
			lo.add(roleid);
		}
		return commonDao.queryObjList(sql.toString(), lo.toArray(), AddcashEntity.class);
	}
}
